package com.liliudong.rommath.api.sys.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.liliudong.rommath.biz.sys.param.SysAuthLoginParam;
import com.liliudong.rommath.biz.sys.result.SysAuthLoginResult;
import com.liliudong.rommath.biz.sys.service.SysUserService;
import com.liliudong.rommath.common.R;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统认证 控制层.
 *
 * @author liliudong
 * @date 2025年01月03日 22:15
 */
@RestController
@RequestMapping("/sys/auth")
@RequiredArgsConstructor
public class SysAuthController {

    private final SysUserService sysUserService;

    /**
     * 登录
     *
     * @param sysAuthLoginParam sys身份验证登录参数
     * @return {@link R }<{@link SysAuthLoginResult }>
     */
    @SaIgnore
    @PostMapping("/login")
    public R<SysAuthLoginResult> login(@RequestBody @Validated SysAuthLoginParam sysAuthLoginParam) {
        SysAuthLoginResult result = sysUserService.login(sysAuthLoginParam);
        return R.ok(result);
    }
}
